using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using MULENetworking;

namespace MULEServer
{
    [Serializable]
    public class RemoteChatRoom : MarshalByRefObject, IChatRoom
    {
        private ArrayList msgLog;
        private ArrayList userList;
        private string recentMsg;

        public RemoteChatRoom()
        {
            msgLog = new ArrayList();
            userList = new ArrayList();
            recentMsg = "none";
        }

        #region IChatRoom Members

        public ArrayList chatList
        {
            get
            {
                return msgLog;
            }
            set
            {
                msgLog = value;
            }
        }

        public string lastMessage
        {
            get
            {
                return recentMsg;
            }
            set
            {
                recentMsg = value;
            }
        }

        public ArrayList chatMembers
        {
            get
            {
                return userList;
            }
            set
            {
                userList = value;
            }
        }

        public IPlayer AddUser(string desiredName)
        {
            RemotePlayer newPlayer = new RemotePlayer(desiredName);
            //TODO: add code to check if user already exists
            
            return newPlayer;
        }

        public IGameTasks StartGame(IPlayer player1, IPlayer player2, IPlayer player3, IPlayer player4)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }
}
